package masterlink.sarPoint.vo;

import java.io.Serializable;

public class FitxTick implements Serializable{
	private static final long serialVersionUID = 294265733818237637L;
	private int ctime=0;//成交時間
	private int hPrice;//最高價
	private int lPrice;//最低價
	private int oPrice;//開盤價
	private int cPrice;//收盤價
	private int qty;//口數
	private int price;//價格
	private long qtyPrice;//加權
	private int sQty;//總量
	public void setData(int ctime,int price,int qty){
		if(this.ctime==0){
			this.oPrice = price;
			this.hPrice = price;
			this.lPrice = price;
			this.cPrice = price;
			this.ctime = ctime;
			this.sQty = qty;
			this.qtyPrice = qty * price;
			return;
		}
		if(price>this.hPrice){
			this.hPrice = price;
		}
		if(price<this.lPrice){
			this.lPrice = price;
		}
		this.qtyPrice=this.qtyPrice+(qty*price);
		this.sQty = this.sQty + qty;
		this.cPrice = price;
	}
	
	public int getCtime() {
		return ctime;
	}

	public double getWegPrice(){
		return (double)qtyPrice / (double)sQty;
	}
	public int gethPrice() {
		return hPrice;
	}

	public int getlPrice() {
		return lPrice;
	}

	public int getoPrice() {
		return oPrice;
	}

	public int getcPrice() {
		return cPrice;
	}

	public long getQtyPrice() {
		return qtyPrice;
	}

	public int getsQty() {
		return sQty;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("FitxTick [ctime=");
		builder.append(ctime);
		builder.append(", hPrice=");
		builder.append(hPrice);
		builder.append(", lPrice=");
		builder.append(lPrice);
		builder.append(", oPrice=");
		builder.append(oPrice);
		builder.append(", cPrice=");
		builder.append(cPrice);
		builder.append(", qty=");
		builder.append(qty);
		builder.append(", price=");
		builder.append(price);
		builder.append(", qtyPrice=");
		builder.append(qtyPrice);
		builder.append(", sQty=");
		builder.append(sQty);
		builder.append("]");
		return builder.toString();
	}
	
}
